package com.distribute.application.api.utils.mobile;

import java.io.IOException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class TextMessageRunnable implements Runnable {

	private final Logger logger = LoggerFactory.getLogger(this.getClass());

	private TextMessageEntity messageEntity;
	private TextMessageSender sender;
	private String phoneNum;
	private String msg;

	public void setPhoneNum(String phoneNum) {
		this.phoneNum = phoneNum;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public TextMessageRunnable() {
		super();
		messageEntity = new TextMessageEntity();
		messageEntity.setMessageServer("http://yunpian.com/v1/sms/send.json");//云片短信服务
		sender = TextMessageSender.getInstance();
	}

	public void run() {
		String response;
		try {
			response = sender.sendMessage(messageEntity, this.msg,
					this.phoneNum);
			logger.info("send text msg to :" + phoneNum + " " + this.msg + " response:" + response);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}